<template>
  <div class="add-cart">
    <div class="left" >
      <span class="iconfont" @click.stop.prevent="readucefood()">&#xe65a;</span>
    </div>
    <div class="middle" >
      <span class="display">{{food.count}}</span>
    </div>
    <div class="left">
      <span class="iconfont" @click.stop.prevent="addfood()">&#xe65c;</span>
    </div>
    <!-- <van-stepper v-model="value" value="value" theme="round"
    button-size="22" input-width="16px" @change="onchange" /> -->
  </div>
</template>

<script>
import Vue from 'vue'
export default {
  name: 'AddCart',
  props: {
    food: {
      type: Object
    }
  },
  data () {
    return {
      // value: 0
    }
  },
  methods: {
    // onchange (value) {
    //   console.log(value)
    // },
    addfood () {
      if (!this.food.count) {
        Vue.set(this.food, 'count', 1)
      } else {
        this.food.count++
      }
      // console.log(this.food)
    },
    readucefood () {
      if (this.food.count > 0) {
        this.food.count--
      } else {
        return ''
      }
    }
  },
  mounted () {
    // console.log(this.food)
  }
}
</script>

<style scoped lang="scss">
.add-cart {
  display: flex;
  .left {
    width: 24px;
    height: 24px;
    .iconfont {
      color: rgb(1, 162, 255);
      font-size: 20px;
    }
  }
  .middle{
    display: inline-block;
    font-size: 14px;
    .display{}
  }
}
</style>
